#ifndef __FILE_H
#define __FILE_H
#include"global.h"
#include"inode.h"
#include"dir.h"

#define MAX_OPEN_CNT 32
//stand input output fd number
typedef enum{
	stdin_no,
	stdout_no,
	stderr_no
}std_fd;

enum whence{
	//the value is offset	
	SEEK_SET=1,
	//the value will add fd_pos
	SEEK_CUR,
	//the value is from file size
	SEEK_END
};

typedef enum{
	O_RDONLY,
	O_WRONLY,
	O_RDWR,
	O_CREAT=4
}oflag;

struct file{
	uint32_t fd_pos;
	oflag f_flag;
	struct winode* inode;
};

struct stat{
	uint32_t i_no;
	uint32_t i_size;
	fs_type ft;
};
const char* sub_path(const char* path,char* name);	
void abs_path(char* dest,char* src);
int sys_open(const char* path,oflag flag);
void sys_close(int32_t fd);
int32_t sys_unlink(const char* path);
int32_t sys_mkdir(const char* path);
int32_t sys_stat(const char* path,struct stat* st);
int32_t sys_write(int32_t fd,void* src,uint32_t cnt);
int32_t sys_read(int32_t fd,void* buffer,uint32_t cnt);
int32_t sys_lseek(int32_t fd,int32_t offset,uint8_t whence);
#endif
